//二维前缀和
//测试链接 https://www.nowcoder.com/practice/99eb8040d116414ea3296467ce81cbbc
import java.util.Scanner;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class TwoDimensionalPrefixSum {
    public static long[][] arr = new long[1001][1001];

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        while(in.nextToken() != StreamTokenizer.TT_EOF){
            int n = (int) in.nval;
            in.nextToken();
            int m = (int) in.nval;
            in.nextToken();
            int q = (int) in.nval;
            in.nextToken();

            //构造数据
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                    int cur = (int)in.nval;
                    in.nextToken();
                    arr[i][j] = arr[i-1][j] + arr[i][j-1] + cur - arr[i-1][j-1];
                }
            }

            //查询次数
            for(int i = 0; i < q; i++){
                int x1 = (int)in.nval;
                in.nextToken();
                int y1 = (int)in.nval;
                in.nextToken();
                int x2 = (int)in.nval;
                in.nextToken();
                int y2 = (int)in.nval;
                in.nextToken();


                long ret = arr[x2][y2] - arr[x2][y1-1] - arr[x1-1][y2] + arr[x1-1][y1-1];
                out.println(ret);
            }

        }
        out.flush();
        br.close();
        out.close();
    }
}
